
<template>
<form style="height:100%;width:100%" action="/user/login" method="post">
    <div class="login-wrap" >
        <div class="ms-login" name='u_p'>
            
            <div style="height:10%;width:8%;float:right;" class="CS_1" @click="toPhone()"> </div>
            <br>
            <div class="ms-title" >
                <div style="margin-left: 30px;font-size: 31px;">土地整治智能监管平台</div></div>
                <el-form :model="param" :rules="rules" ref="login" label-width="0px" class="ms-content">
                <el-form-item prop="username">
                    <el-input v-model="param.userName" placeholder="用户名" name="usernmae">
                        <el-button slot="prepend" icon="el-icon-s-custom"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input
                        type="password"
                        placeholder="密码"
                        v-model="param.passWord"
                        name="password"
                        @keyup.enter.native="submitForm()"
                    >
                        <el-button slot="prepend" icon="el-icon-lock"></el-button>
                    </el-input>
                </el-form-item>
                </el-form>
             <br>
                <div class="login-btn">
                    <el-button type="primary" @click="submitForm()">登&nbsp;录</el-button>
                    <!-- <el-button type="primary" value="login">登&nbsp;录</el-button> -->
                </div>

        </div>
        <div class="ms-login" name='phone' style="display:none">
            
            <div style="height:10%;width:8%;float:right;" class="D_2" @click="toUP()"> </div>
            <br>

            <div class="ms-title" >
                <div style="margin-left: 7%;font-size: 31px;">手机扫码&nbsp;安全登录</div></div>
                <div class="erweima"  style="margin-left: 15%;height:70%;width:70%"></div>
                <div class="login-btn">
                    <span style="color:#fff">打开<span style="color:#0069f8">微信</span>扫一扫登录</span>
                </div>
        </div>
    </div>
</form>
</template>

<script>
import user from '@/api/user/login.js'
import QRCode from 'qrcodejs2'
export default {
    data: function() {
        return {
            param: {
                userName: '',
                passWord: '',
            },
            value :true,
            rules: {
                userName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
                passWord: [{ required: true, message: '请输入密码', trigger: 'blur' }],
            },
        };
    },
    mounted() {
    this.creatQrCode();
},
    methods: {
        creatQrCode() {
        var qrcode = new QRCode(this.$refs.qrCodeUrl, {
            text: 'xxxx', // 需要转换为二维码的内容
            width: 100,
            height: 100,
            colorDark: '#000000',
            colorLight: '#ffffff',
            correctLevel: QRCode.CorrectLevel.H
        })
    },
        submitForm() {
           
            this.$refs.login.validate(valid => {
                if (valid) {
                    

                    user.login(this.param).then(rep =>{
                        this.$message.success('登录成功');
                        localStorage.setItem('ms_username', this.param.username);
                         this.$router.push('/dashboard');
                    })
                } else {
                    this.$message.error('请输入账号和密码');
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        toPhone(){
                $("[name='u_p']").hide();
                $("[name='phone']").show();
        },
        toUP(){
             $("[name='u_p']").show();
            $("[name='phone']").hide();
        }
    },
};
</script>

<style lang="less" scoped>
.erweima{
    background-image: url(../../assets/img/login/erweima.jpg);
    background-size: 100% 100%;
    z-index: 1;
}
/deep/ .CS_1{
    background-image: url(../../assets/img/login/ewm.png);
    background-size: 100% 100%;
    cursor: pointer;
}
/deep/  .D_2{
    background-image: url(../../assets/img/login/pc.png);
    background-size: 100% 100%;
    cursor: pointer;
}
.el-button--primary{
    background-color:orange;
    border-color:orange
}
.login-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    background-image: url(../../assets/img/login/tldly.jpg);
    background-size: 100% 100%;
}
.ms-title {
    width: 100%;
    line-height: 50px;
    text-align: center;
    font-size: 28px;
    font-family: '思源黑 Medium ';
    color:#444444;
    
    /* border-bottom: 1px solid #ddd; */
}
.ms-login {
    position: absolute;
    left: 50%;
    top: 30%;
    width: 25%;
    margin: -23px 0 0 -10%;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.3);
    overflow: hidden;
    height: 40%;
}
.el-input--small .el-input__inner{
    height: 43px;
}
.el-button--primary:focus, .el-button--primary:hover{
    background-color: chartreuse;
}
.ms-content {
    height: 28%;
    width: 59%;
    padding: 30px 30px;
    background-color: #fff;
    border: 0px solid transparent;
    border-radius: 10px;
    margin-top: 6%;
    margin-left: 14%;
}
.login-btn {
    text-align: center;
    margin-top: 5%;
}
.login-btn button {
    border: 0px solid transparent;
    border-radius: 7px;
    font-size: 23px;
    width: 72%;
    padding: 0px 0px;
    height: 42px;
    margin-bottom: 5px;
}
.login-tips {
    font-size: 12px;
    line-height: 30px;
    color: #fff;
}

</style>